package com.hao.baby.utils;

import java.util.Date;
import java.util.Random;

public class Util {
	
	public static String YMDhms = "yyyy-MM-dd HH:mm:ss";
	public static final String YMDhm = "yyyy-MM-dd HH:mm";
	public static final String YMD = "yyyy-MM-dd";

	public static void main(String[] args) {
//		FileUtils
	}
	
	public static String getDiffTime(Date date){
		long time = date.getTime();
		return getDiffTime(time);
	}
	
	public static String getDiffTime(long time){
		long minute = (System.currentTimeMillis()-time)/1000/60;
		if (minute < 1)
			return "刚刚";
		else if (minute >=1 &&minute < 60){
			return minute+"分钟前";
		}
		else if (minute < 60*24){
			return (minute/60)+"小时前";
		}
		else if (minute < 24*60*365){
			return (minute/1440)+"天前";
		}
		else{
			return (minute/(24*60*365))+"年前";
		}
	}
	
	public static String getRandomPath(int length,int max){
		StringBuffer buffer = new StringBuffer("/");
		Random r = new Random() ;
		for (int i=0;i<length;i++){
			buffer.append(r.nextInt(max)+"/");
		}
		return buffer.toString();
	}
	
	public static class Datasource{
		public final static int BEVA = 10;
		public final static int QIPAOXIAN = 20;
		
		public static String getName(int code){
			switch (code) {
			case BEVA:
				return "贝瓦";
			case QIPAOXIAN:
				return "起跑线";
			default:
				return "网络";
			}
		}
	}

}
